package semana3.strings.ejercicios.ej19_palindromo;

import java.util.Scanner;

import semana3.strings.cadenasdecaracteres.CadenasDeCaracteres;

public class FrasePalindroma {

	private Scanner scan;
	private String frase;
	private CadenasDeCaracteres cdc;

	// private String fraseSinEspacios;
	// private String fraseSinTilde;

	public FrasePalindroma() {
		inicializar();
		eliminarEspacios(this.frase);
		eliminarTildes(this.frase);
		convertirAMinuscula(this.frase);
		System.out.println(this.frase);
		esPalindromo();

	}

	private void esPalindromo() {
		String reves = this.frase;
		reves = cdc.cadeaReves(reves);
		if (this.frase.equals(reves)) {
			System.out.println("Es Palindromo");
		} else {
			System.out.println("NO es Palindromo");
		}
	}

	private void convertirAMinuscula(String frase2) {
		String sol = "";

		for (int i = 0; i < this.frase.length(); i++) {
			sol = sol + cdc.aMinuscula(this.frase.charAt(i));

		}
		this.frase = sol;

	}

	private void eliminarTildes(String fraseSinEspacios2) {
		String sol = "";

		for (int i = 0; i < this.frase.length(); i++) {
			sol = sol + cdc.quitarTildes(this.frase.charAt(i));
		}
		this.frase = sol;
	}

	private void eliminarEspacios(String frase) {
		this.frase = new CadenasDeCaracteres().quitarBlancos(frase);

	}

	private void inicializar() {
		scan = new Scanner(System.in);
		cdc = new CadenasDeCaracteres();
		System.out.println("Introduce una frase: ");
		frase = scan.nextLine();
	}

	public static void main(String[] args) {

		new FrasePalindroma();
	}
}
